# models.py
from django.db import models

class BayAssignedSegment(models.Model):
    assignment_id = models.AutoField(primary_key=True, verbose_name='分配ID')
    bay_description = models.TextField(null=True, blank=True, verbose_name='胎位描述')
    bay_number = models.CharField(max_length=50, verbose_name='胎位编号')
    bay_length = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='胎位长度(m)')
    bay_width = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='胎位宽度(m)')
    labor_team = models.CharField(max_length=100, null=True, blank=True, verbose_name='劳务队')
    ship_number = models.CharField(max_length=50, verbose_name='船号')
    segment_schedule_id = models.CharField(max_length=255, null=True, blank=True, verbose_name='分段计划ID')
    segment_number = models.CharField(max_length=50, verbose_name='分段号')
    planned_start_time = models.DateTimeField(null=True, blank=True, verbose_name='计划开始时间')
    planned_end_time = models.DateTimeField(null=True, blank=True, verbose_name='计划结束时间')
    latest_end_time = models.DateTimeField(null=True, blank=True, verbose_name='最晚完工时间')

    def __str__(self):
        return f"{self.ship_number} - {self.segment_number}"

    class Meta:
        db_table = 'bay_assigned_segments'
        verbose_name = '胎位分配信息'
        verbose_name_plural = '胎位分配信息列表'